#!/bin/bash

if [[ "$(uname -s)" == "Darwin" ]]; then
	temp_dir="$(mktemp -d)"
	curl -SsL https://gitee.com/hevey88/brew-user/raw/main/Casks/rectangle.rb -o "$temp_dir"/rectangle.rb
	brew install --cask --no-quarantine "$temp_dir"/rectangle.rb
	defaults write com.knollsoft.Rectangle alternateDefaultShortcuts -bool true
	defaults write com.knollsoft.Rectangle centerHalf '{keyCode = 46;modifierFlags = 786432;}'
	defaults write com.knollsoft.Rectangle rightHalf '{keyCode = 37;modifierFlags = 786432;}'
	defaults write com.knollsoft.Rectangle leftHalf '{keyCode = 4;modifierFlags = 786432;}'
	defaults write com.knollsoft.Rectangle launchOnLogin -bool true
	defaults write com.knollsoft.Rectangle hideMenubarIcon -bool true
	open -a Rectangle
	# defaults delete com.knollsoft.Rectangle
else
	echo "Only for macOS"
fi
